package com.bawei.module_equipment.ui.equipment

import android.util.Log
import androidx.lifecycle.MutableLiveData
import com.bawei.lib_common.base.BaseViewModel
import com.bawei.lib_common.base.state.Failed
import com.bawei.lib_common.base.state.Loading
import com.bawei.lib_common.base.state.RequestEvent
import com.bawei.lib_common.base.state.Success
import com.bawei.module_equipment.model.EquipmentModelItem
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.asSharedFlow
import javax.inject.Inject

/**
 *作者：lxy
 *功能:
 *时间：2025/6/13
 */
@HiltViewModel
class EquipmentViewModel @Inject constructor(private val mRepository: EquipmentRepository) :
    BaseViewModel() {


    private val _equipPageFlow = MutableSharedFlow<RequestEvent>()
    val equipPageFlow = _equipPageFlow.asSharedFlow()

    var mEquipments = listOf<EquipmentModelItem>()

    fun inspection(){
        execute(
            action = mRepository.inspection(),
            onFinish = {
                if (it.data.isNotEmpty()) {
                    mEquipments =  it.data
                    Log.d("TAG", "inspection: "+mEquipments.size)
                    _equipPageFlow.emit(Success)
                }
            }
        )
    }
}